package com.hw.controller.shoppingCart;


import com.hw.entity.dto.shoppingCart.ShoppingCartDTO;
import com.hw.model.ResponseResult;
import com.hw.service.shoppingCart.ShoppingCartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 购物车（已点列表） Controller
 *
 * @author xuguang
 * @date 2021-06-29
 */
@Api(tags = "购物车（已点列表）")
@RestController
@RequestMapping("/shoppingCart" )
public class ShoppingCartController {

    @Autowired
    private ShoppingCartService shoppingCartService;

    @ApiOperation(value = "重置购物车")
    @GetMapping("/resetFood")
    public ResponseResult<?> resetFood(String taskId) {
        return ResponseResult.success(shoppingCartService.resetFood(taskId));
    }

    @ApiOperation(value = "保存已点列表")
    @PostMapping("/save")
    public ResponseResult<?> saveShoppingCart(@RequestBody List<ShoppingCartDTO> shoppingCartDTOs) {
        return ResponseResult.success(shoppingCartService.save(shoppingCartDTOs));
    }

    @ApiOperation(value = "回显已点列表")
    @GetMapping("/getData")
    public ResponseResult<?> getData(String taskId) {
        return ResponseResult.success(shoppingCartService.getData(taskId));
    }

}
